package com.wl.mvi.home.model.repository

import com.wl.lib.http.CommonRetrofitClient
import com.wl.lib.mvi.BaseData
import com.wl.lib.mvi.BaseRepository
import com.wl.mvi.home.model.bean.Article
import com.wl.mvi.home.model.bean.Banner
import retrofit2.http.GET
import retrofit2.http.Path


// Created by wangliang on 2024/4/25.
class HomeRepository : BaseRepository() {

    private interface HomeApi {

        @GET("banner/json")
        suspend fun getBanner(): BaseData<List<Banner>>

        @GET("article/list/{page}/json")
        suspend fun getArticle(@Path("page") page: Int): BaseData<Article>

    }

    private val service by lazy { CommonRetrofitClient.create(HomeApi::class.java) }

    suspend fun getWanData(): BaseData<List<Banner>> {
        return executeRequest { service.getBanner() }
    }

    suspend fun getArticle(page: Int): BaseData<Article> {
        return executeRequest { service.getArticle(page) }
    }
}